package cj.web.admin.dao;
/*
 *  
 *  
*/
import java.util.List;
import java.util.Map;

import net.paoding.rose.jade.annotation.DAO;
import net.paoding.rose.jade.annotation.SQL;
import net.paoding.rose.jade.annotation.SQLParam;
import cj.web.admin.domain.Area;

/**
 * 
 * @author 
 *
 */
@DAO
public interface AreaDAO{
	
	@SQL("SELECT * FROM Area WHERE deleteFlag=1 ORDER BY id ")
    List<Area> queryAll();
	
	@SQL("SELECT * FROM Area WHERE deleteFlag=1 #if(:t.name!=''){ AND name LIKE '%##(:t.name)%' } ORDER BY updateAt DESC LIMIT :t.start,:t.length ")
    List<Area> query(@SQLParam("t") Area area);
	
	@SQL("SELECT count(*) FROM Area WHERE deleteFlag=1 #if(:t.name!=''){ AND name LIKE '%##(:t.name)%' } ")
    int querysize(@SQLParam("t") Area area);
    
    @SQL("SELECT * FROM Area WHERE id=:1")
    Area queryById(int id);
    
    @SQL("INSERT INTO Area (code,name,deleteFlag,createAt,createUser,updateAt,updateUser) VALUES (:t.code,:t.name,1,now(),:t.createUser,now(),:t.updateUser)")
    void create(@SQLParam("t") Area area);
	
	@SQL("UPDATE Area SET code=:t.code,name=:t.name,updateAt=now(),updateUser=:t.updateUser WHERE id=:t.id")
    void update(@SQLParam("t") Area area);
    
    @SQL("UPDATE Area SET deleteFlag=0 WHERE id=:1")
    void deleteById(int id);

    @SQL("SELECT id,name FROM Area WHERE deleteFlag=1")
	List<Map> asAreaEnum();
}